package com.redoor.app.stake.basicdata.service.impl;

import com.redoor.app.stake.basicdata.dao.BaseFeeModelRelMapper;
import com.redoor.app.stake.basicdata.model.BaseFeeModelRel;
import com.redoor.app.stake.basicdata.service.BaseFeeModelRelService;
import com.redoor.app.stake.common.utils.UUIDTool;
import com.redoornetwork.framework.mybatis.service.AbstractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * Created by wangjunlei on 2018-03-14 10:38:41.
 */
@Service
public class BaseFeeModelRelServiceImpl extends AbstractService<BaseFeeModelRel, String> implements BaseFeeModelRelService {

    @Autowired
    private BaseFeeModelRelMapper baseFeeModelRelMapper;

    @Override
    public int saveModel(BaseFeeModelRel info) {

        if (info==null){
            return 0;
        }

        if (info.getUuid()==null || info.getUuid().trim().length()==0){
            info.setUuid(UUIDTool.getUUID());
        }
        if (info.getBinddate()==null){
            info.setBinddate(new Date());
        }

        //TODO 需要根据模型ID查询最大最小收费
        int insert = baseFeeModelRelMapper.insert(info);

        return insert;
    }

    @Override
    public BaseFeeModelRel selectOne(BaseFeeModelRel param) {
        return this.baseFeeModelRelMapper.selectOne(param);
    }

    @Override
    public int updateByPrimaryKeySelective(BaseFeeModelRel param) {
       return this.baseFeeModelRelMapper.updateByPrimaryKeySelective(param);
    }
}
